package fastiot

import org.fastiot.gateway.Connector
import org.fastiot.gateway.RouteConfiguration
import org.springframework.beans.factory.annotation.Value

class BootStrap {

    @Value('${gateway.default.embedded}')
    private boolean embeddedGateway
    @Value('${gateway.default.host}')
    private String gatewayHost
    @Value('${gateway.default.port}')
    private Integer gatewayPort

    RouteConfiguration.SocketAccessRegistrar accessRegistrar

    def init = { servletContext ->
        if(embeddedGateway) {
            accessRegistrar.register(new Connector(type: Connector.Type.Server, host: gatewayHost, port: gatewayPort))
        }
    }
    def destroy = {
    }
}
